<template>
  <div class="interact_box">
    <div class="tab_box">
      <p
        v-for="(item, index) in tabList"
        :key="index"
        :class="{ active: index === chooseIndex }"
        @click="chooseTab(item, index)"
      >
        {{ item }}
      </p>
    </div>
    <div class="tab_body">
      <div class="tab_body_box" v-show="active === '简介'">
        <img
          src="@/assets/img/trtc/ceshi_jianjie.png"
          class="brief_introduction_img"
          alt=""
        />
      </div>
      <div class="tab_body_box" v-show="active === '讲师'">
        <div
          v-for="(item, index) in teacherList"
          :key="index"
          class="teacher_box"
        >
          <div class="teacher_info">
            <div
              class="avater"
              :style="{ backgroundImage: 'url(' + item.photo + ')' }"
            ></div>
            <div class="title">
              <p class="name">{{ item.name }}</p>
              <p class="introduce">{{ item.title }}</p>
            </div>
          </div>
          <div class="teacher_desc">
            {{ item.desc }}
            <!-- <textOverflow :content="item.desc">
            </textOverflow> -->
          </div>
        </div>
      </div>
      <div class="tab_body_box" v-show="active === '聊天'">
        <slot> </slot>
      </div>
      <div class="tab_body_box" v-show="active === '资料'">
        <div class="module_class">
          <div class="info">
            <img src="@/assets/img/trtc/icon-database-library.png" alt="" />
            <span>资料库</span>
          </div>
          <div class="right-arrow">></div>
        </div>
        <div class="data_list" v-for="(item, index) in dataList" :key="index">
          <div class="data_info">
            <div
              class="poster"
              :style="{ backgroundImage: 'url(' + item.post + ')' }"
            ></div>
            <div class="right_desc">
              <p class="name">{{ item.title }}</p>
              <p class="other">
                <span class="page-size">共{{ item.pageNum }}页</span>
                <img src="@/assets/img/trtc/icon-trash.png" alt="" />
              </p>
            </div>
          </div>
          <div class="data_set">
            <div class="browse-checkbox">
              <el-checkbox v-model="item.checked">允许浏览</el-checkbox>
            </div>
            <div class="button">投屏演示</div>
          </div>
        </div>
      </div>
      <div class="tab_body_box" v-show="active === '问卷'">
        <div class="module_class">
          <div class="info">
            <img
              style="width: 15px; height: 16px"
              src="@/assets/img/trtc/icon-question-library.png"
              alt=""
            />
            <span>问卷库</span>
          </div>
          <div class="right-arrow">></div>
        </div>
        <div class="data_list" v-for="(item, index) in quesList" :key="index">
          <div class="data_info">
            <div
              class="poster"
              :style="{ backgroundImage: 'url(' + item.post + ')' }"
            ></div>
            <div class="right_desc">
              <p class="name">{{ item.title }}</p>
              <p class="other">
                <span class="page-size">未填写</span>
                <img src="@/assets/img/trtc/icon-trash.png" alt="" />
              </p>
            </div>
          </div>
          <div class="data_set">
            <div></div>
            <div class="button">发起调研</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import textOverflow from "@/components/textOverflow";
import { mapGetters } from "vuex";
import { ROOM_STATUS, USER_TYPE } from "../../../util/constants";
export default {
  data() {
    return {
      ROOM_STATUS,
      chooseIndex: 0,
      active: "简介",
      teacherList: [
        {
          name: "张明文",
          photo:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "主任医师、教授、博士生导师",
          desc:
            "绍绍信息此处展示讲师的介绍信息信息此处展示讲师的介绍信息，此处展示讲师的介绍上海市胸科医院呼吸内科，此处展示讲师的介绍信息此处展示讲师的介绍信息，此处展示讲师的介绍",
        },
        {
          name: "张明文",
          photo:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "主任医师、教授、博士生导师",
          desc:
            "上海市胸科医院 | 呼吸内科，此处展示讲师的介绍信息此处展示讲师的介绍信息，此处展示讲师的介绍",
        },
        {
          name: "张明文",
          photo:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "主任医师、教授、博士生导师",
          desc:
            "上海市胸科医院 | 呼吸内科，此处展示讲师的介绍信息此处展示讲师的介绍信息，此处展示讲师的介绍",
        },
        {
          name: "张明文",
          photo:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "主任医师、教授、博士生导师",
          desc:
            "上海市胸科医院 | 呼吸内科，此处展示讲师的介绍信息此处展示讲师的介绍信息，此处展示讲师的介绍",
        },
        {
          name: "张明文",
          photo:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "主任医师、教授、博士生导师",
          desc:
            "上海市胸科医院 | 呼吸内科，此处展示讲师的介绍信息此处展示讲师的介绍信息，此处展示讲师的介绍",
        },
        {
          name: "张明文",
          photo:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "主任医师、教授、博士生导师",
          desc:
            "上海市胸科医院 | 呼吸内科，此处展示讲师的介绍信息此处展示讲师的介绍信息，此处展示讲师的介绍",
        },
      ],
      dataList: [
        {
          post:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "资料名称资料名称",
          pageNum: "16",
          checked: true,
        },
        {
          post:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "资料名称资料名称",
          pageNum: "16",
          checked: true,
        },
        {
          post:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "资料名称资料名称",
          pageNum: "16",
          checked: true,
        },
        {
          post:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "资料名称资料名称",
          pageNum: "16",
          checked: true,
        },
        {
          post:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "资料名称资料名称",
          pageNum: "16",
          checked: true,
        },
        {
          post:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "资料名称资料名称",
          pageNum: "16",
          checked: true,
        },
      ],
      quesList: [
        {
          post:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "资料名称资料名称",
          pageNum: "16",
          checked: true,
        },
        {
          post:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "资料名称资料名称",
          pageNum: "16",
          checked: true,
        },
        {
          post:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "资料名称资料名称",
          pageNum: "16",
          checked: true,
        },
        {
          post:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "资料名称资料名称",
          pageNum: "16",
          checked: true,
        },
        {
          post:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "资料名称资料名称",
          pageNum: "16",
          checked: true,
        },
        {
          post:
            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg",
          title: "资料名称资料名称",
          pageNum: "16",
          checked: true,
        },
      ],
    };
  },
  components: {
    textOverflow,
  },
  computed: {
    // 获取当前会议状态
    ...mapGetters(["roomInfo", "userInfo"]),
    tabList() {
      // 如果当前会议是未开始,
      if (this.roomInfo.status == this.ROOM_STATUS.not_started) {
        // 如果用户是讲者和观众USER_TYPE.lecturer audience
        if (
          this.userInfo.userType == USER_TYPE.audience ||
          this.userInfo.userType == USER_TYPE.lecturer
        ) {
          return ["简介", "讲师", "聊天"];
        } else {
          return ["简介", "讲师", "聊天", "资料", "问卷"];
        }
      } else {
        return ["简介", "讲师", "聊天", "资料", "问卷"];
      }
    },
  },
  mounted() {},
  methods: {
    chooseTab(item, index) {
      this.active = item;
      this.chooseIndex = index;
    },
  },
};
</script>

<style lang="scss" scoped>
.interact_box {
  flex: 1;
  display: flex;
  flex-direction: column;
  .tab_box {
    width: 100%;
    padding: 10px;
    height: 38px;
    padding-bottom: 7px;
    @include flexAlign();
    background: #fff;
    box-sizing: border-box;
    display: flex;
    p {
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: rgba(0, 0, 0, 0.65);
      line-height: 20px;
      flex: 1;
      text-align: center;
      position: relative;
      cursor: pointer;
    }
    .active {
      color: #475aa7;
      font-weight: 500;
    }
    .active::after {
      position: absolute;
      content: "";
      bottom: 0;
      width: 50%;
      height: 2px;
      background: #475aa7;
      left: 50%;
      bottom: -7px;
      transform: translateX(-50%);
    }
  }
  .tab_body {
    flex: 1;
    box-sizing: border-box;
    overflow: auto;
    position: relative;
    .tab_body_box {
      height: 100%;
      position: absolute;
      box-sizing: border-box;
      padding-top: 8px;
      padding-bottom: 8px;
      right: 8px;
      left: 8px;
      .brief_introduction_img {
        width: 100%;
        height: auto;
      }
    }
  }
}
.teacher_box {
  background: #fff;
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  margin-bottom: 9px;
  border-radius: 2px;
  .teacher_info {
    display: flex;
    align-items: center;
    .avater {
      width: 50px;
      height: 50px;
      border-radius: 4px;
      background-size: cover;
      background-position: center;
      margin-right: 8px;
    }
    .title {
      .name {
        font-size: 15px;
        font-weight: 500;
        color: rgba(0, 0, 0, 0.65);
        line-height: 21px;
      }
      .introduce {
        margin-top: 4px;
        font-size: 11px;
        font-weight: 400;
        color: rgba(0, 0, 0, 0.5);
        line-height: 16px;
      }
    }
  }
  .teacher_desc {
    font-size: 14px;
    margin-top: 9px;
    @include ellipsis(2);
  }
}
.module_class {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  padding: 13px;
  margin: 8px auto;
  box-sizing: border-box;
  cursor: pointer;
  .info {
    display: flex;
    align-items: center;
  }
  .right-arrow {
    // width: 16px;
    // height: 16px;
    font-size: 16px;
  }
  img {
    width: 20px;
    height: 16px;
    margin-right: 8px;
  }
}
.data_list {
  background: #fff;
  padding: 12px 4px;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 8px;
  .data_info {
    display: flex;
    align-items: center;
    padding: 0 12px;
    box-sizing: border-box;
    padding-bottom: 8px;
    border-bottom: solid 1px #f0f0f0;

    .poster {
      width: 62px;
      height: 62px;
      margin-right: 8px;
      border-radius: 2px;
      background-size: cover;
      background-position: center;
    }
    .right_desc {
      flex: 1;
      .name {
        font-size: 16px;
        font-weight: 400;
        color: rgba(0, 0, 0, 0.65);
        line-height: 26px;
      }
      .other {
        display: flex;
        margin-top: 6px;
        align-items: center;
        justify-content: space-between;
        .page-size {
          font-size: 12px;
          font-weight: 400;
          color: rgba(0, 0, 0, 0.5);
          line-height: 17px;
        }
        img {
          width: 14px;
          height: 15px;
        }
      }
    }
  }
  .data_set {
    display: flex;
    margin-top: 8px;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    .browse-checkbox {
    }
    .button {
      height: 32px;
      background: #475aa7;
      border-radius: 4px;
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #ffffff;
      line-height: 22px;
      display: flex;
      justify-content: center;
      align-items: center;
      padding: 0 16px;
    }
  }
}
</style>